//导入路由相关的函数
import { createRouter, createWebHashHistory,createWebHistory } from 'vue-router'
// 导入路由相关的组件
import Login from './view/Login.vue'
import About from './view/About.vue'
import Main from './view/Main.vue'
import User from './view/user/index.vue'
import Mode from './view/user/mode.vue'
import Draw from './view/user/draw.vue'
import Product from './view/product/index.vue'
//路由懒加载
const Category = () => import('./view/product/category.vue')
// 定义路由，每个路由都需要映射到一个组件。
const routes = [
  { path: '/', component: Login },
  { path: "/pro", component: Product },
  { path: '/about', component: About }, 
  
  
  {
    path: '/main', component: Main, name: "main",
    // 嵌套路由/子路由
    children: [
      { path: "user", component: User },
      { path: "mode", component: Mode },
      { path: "draw", component: Draw },
      { path: "product", component: Product },
      { path: 'category', component: Category },
    ]
  },
]

// 创建路由实例并传递 `routes` 配置
const router = createRouter({
  // 内部提供了history 模式的实现。为了简单起见，这里使用 hash 模式。
  history: createWebHistory(),
  routes, // `routes: routes` 的缩写
})

export default router;
